<?php
/////////////////////////////////////////////////////////////////////////////
// 这个文件是 网城创想多用户商城 项目的一部分
//
// Copyright (c) 2007 - 2008 www.shopnc.net
//
// 要查看完整的版权信息和许可信息，请查看源代码中附带的 COPYRIGHT 文件，
// 或者访问 http://www.shopnc.net/ 获得详细信息。
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : shop.php   FILE_PATH : D:\webroot\mulitishop\home\shop.php
 * ....商铺首页
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author 网城创想多用户商城开发团队 php_netproject@yahoo.com.cn
 * @package 
 * @subpackage 
 * @version Wed Sep 26 11:22:48 CST 2007
 */

require ("../global.inc.php");

class ShowShopIndex extends CommonFrameWork{
	/**
	 * 商铺对象
	 *
	 * @var obj
	 */
	var $obj_shop;
	/**
	 * 商铺分类对象
	 *
	 * @var obj
	 */
	var $obj_shopcategory;

	function main(){
		/**
		 * 创建商铺对象
		 */
		if (!is_object($this->obj_shop)){
			require_once("shop.class.php");
			$this->obj_shop = new ShopClass();
		}
		/**
		 * 创建商铺分类对象
		 */
		if (!is_object($this->obj_shopcategory)){
			require_once("shopcategory.class.php");
			$this->obj_shopcategory = new ShopCategoryClass();
		}

		/**
		 * 设置模板路径
		 */
		$this->setsubtemplates("home");

		/**
		 * 语言包
		 */
		$this->getlang("shop");

		switch ($this->_input['action']){
			case "list":
				$this->_shoplist();
				break;
			case "search":
				$this->_searchshop();
				break;
			case "index":
				$this->_show();
				break;
			default:
				$this->_shoplist();
		}

	}

	/**
	 * 商铺列表
	 *
	 */
	function _shoplist(){
		/**
		 * 初始化分页类
		 */
		require_once("commonpage.class.php");
		$obj_page = new CommonPage();
		$obj_page->pagebarnum(15);
		$this->_input['order'] = 1;
		
		if ($this->_input['lang'] == 'zh'){
			$this->_input['keyword'] = $this->unescape($this->_input['keyword']);
		}
		$this->_input['txtShopName'] = $this->_input['keyword'];
		$shop_array = $this->obj_shop->getShopList($this->_input,$obj_page);
		$page_list = $obj_page->show(1);
		//print_r($shop_array);
		$this->output('shop_array',$shop_array);
		$this->output('page_list',$page_list);
		require_once("productclass.class.php");
		$obj_search_cate = new ProductCategoryClass();
		$id = 0;
		$deep = 1;
		$search_cate = $obj_search_cate->listCateById($id, $deep);

		$this->output("search_cate", Common::showForm_Select2("searchcate", "", "", $search_cate));

		$this->showpage('shop.list');
	}

	/**
	 * 显示商铺首页
	 *
	 */
	function _show(){

		$shop_cate_array = $this->obj_shopcategory->getCategoryList(0,$arr);
		//print_r($shop_cate_array);
		$shop_array = $this->obj_shop->getSomeShopList(10);
		//print_r($shop_array);
		$this->output('shop_array',$shop_array);

		require_once("productclass.class.php");
		$obj_search_cate = new ProductCategoryClass();
		$id = 0;
		$deep = 1;
		$search_cate = $obj_search_cate->listCateById($id, $deep);

		$this->output("search_cate", Common::showForm_Select2("searchcate", "", "", $search_cate));

		$this->output('shop_cate_array',$shop_cate_array);
		$this->showpage("shop.index");
	}

	function _searchshop(){
		$category_array = $this->obj_shopcategory->getCategory("0",false);
		$select_category = Common::showForm_Select("slcShopClass","","",Common::getSelectArray($category_array,array('class_id','class_name')),$shop_array['shop_class']);
		// print_r($shop_array);
		$this->output("shop_select_category", $select_category);    //输出商铺分类以下拉框
		$this->output('InfoSelectorTarget',Common::getTargetMenu("search"));
		$this->showpage("shop.search");
	}
}
$shop_index = new ShowShopIndex();
$shop_index->main();
unset($shop_index);
?>